unit uFIltro;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TfFIltro = class(TForm)
    pnl1: TPanel;
    lbl1: TLabel;
    edt1: TEdit;
    pnl2: TPanel;
    lbl2: TLabel;
    edt2: TEdit;
    BitBtn2: TBitBtn;
    pnl3: TPanel;
    lbl3: TLabel;
    edt3: TEdit;
    BitBtn3: TBitBtn;
    pnl4: TPanel;
    BtnOk: TBitBtn;
    BtnCancel: TBitBtn;
    pnl5: TPanel;
    lbl4: TLabel;
    pnl6: TPanel;
    lbl5: TLabel;
    cbb1: TComboBox;
    cbb2: TComboBox;
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure edt2Change(Sender: TObject);
    procedure edt1Change(Sender: TObject);
    procedure edt3Change(Sender: TObject);
    procedure BtnCancelClick(Sender: TObject);
    procedure BtnOkClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fFIltro: TfFIltro;

implementation

uses uProcurar, UDM, uFiltro_loca;

{$R *.dfm}

procedure TfFIltro.BitBtn2Click(Sender: TObject);
begin
  fProcurar:=TfProcurar.Create(self,dm.proc_proprietario);
  try
   fProcurar.BtnProcurar.Click;
   fProcurar.EvDBFind1.DataField := 'NOME_PROPRIETARIO';
   if fProcurar.ShowModal=mrOk then
    begin
      edt2.text := dm.TextoProcura;
    end;
   finally
    fProcurar.Free;
   end;
end;

procedure TfFIltro.BitBtn3Click(Sender: TObject);
begin
  fProcurar:=TfProcurar.Create(self,dm.proc_Inquilino);
  try
   FProcurar.RadioGroup1.Visible := True;
   FProcurar.RadioGroup1.ItemIndex := 0;
   fProcurar.BtnProcurar.Click;
   fProcurar.EvDBFind1.DataField := 'NOME_INQUILINO';
   if fProcurar.ShowModal=mrOk then
    begin
      edt3.text := dm.TextoProcura;
    end;
   finally
    fProcurar.Free;
   end;

end;

procedure TfFIltro.edt2Change(Sender: TObject);
begin
  if (edt2.Text <> '') then
  begin
    edt1.Text := '';
    edt3.Text := '';
  end;
end;

procedure TfFIltro.edt1Change(Sender: TObject);
begin
  if (edt1.Text <> '') then
  begin
    edt2.Text := '';
    edt3.Text := '';
  end;
end;

procedure TfFIltro.edt3Change(Sender: TObject);
begin
  if (edt3.Text <> '') then
  begin
    edt1.Text := '';
    edt2.Text := '';
  end;
end;

procedure TfFIltro.BtnCancelClick(Sender: TObject);
begin
   Close;
end;

procedure TfFIltro.BtnOkClick(Sender: TObject);
begin
  if (edt1.Text <> '') then
    dm.TextoImo := edt1.Text;
  if (edt2.Text <> '') then
    dm.TextoPro := edt2.Text;
  if (edt3.Text <> '') then
    dm.TextoInq := edt3.Text;
  if (cbb1.Text <> '') then
    dm.TextoFormapgto := cbb1.Text;
  if (cbb2.Text <> '') then
    dm.TextoStatus := cbb2.Text;
end;

procedure TfFIltro.FormShow(Sender: TObject);
begin
  if(edt1.Text = '') then
  begin
    edt1.Text := '';
  end ;

  if(edt2.Text = '') then
  begin
    edt2.Text := '';
  end ;

  if(edt3.Text = '') then
  begin
    edt3.Text := '';
  end ;

  cbb1.Text := '';
  cbb2.Text := '';
  edt1.SetFocus;  
end;

end.
